def isPalindrome(str):
    if not str:
        return True
    beg = 0
    end = len(str)-1
    while beg < end:
        if not str[beg].isalnum():
            beg += 1
            continue
        if not str[end].isalnum():
            end -= 1
            continue
        if str[beg].lower() == str[end].lower():
            beg += 1
            end -= 1
        else:
            return False
    return True


if __name__ == '__main__':
    tempt = "A man, a plan, a canal: Panama"
    print(isPalindrome(tempt))
